import Vue from 'vue'
import App from './App.vue'
import router from './router'
// import './plugins/element.js'
import './assets/css/gloable.css'
import './assets/fonts/iconfont.css'
import axios from 'axios'
import TreeTable from 'vue-table-with-tree-grid'
import Nprogress from 'nprogress'
//注册为全局组件
Vue.use(VueQuillEditor)
//配置请求的根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
//请求拦截器，token的携带
axios.interceptors.request.use(config => {
  // console.log(config) //在request拦截器展示
  Nprogress.start()
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // 最后return
  return config
})
//resopnse 关闭进度条 响应拦截器
axios.interceptors.response.use(config => {
  // console.log(config)
  Nprogress.done()
  // config.headers.Authorization = window.sessionStorage.getItem('token') // 最后return
  return config
})
Vue.prototype.$http = axios
Vue.filter('dataFormate', function(origin) {
  const dt = new Date(origin * 1000)
  var y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')
  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})
Vue.config.productionTip = false
Vue.component('tree-table', TreeTable)
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
